package xs;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import xs.src.entity.Role;
import xs.src.mapper.RoleMapper;

import java.io.IOException;
import java.io.InputStream;

public class App {
  public static void main(String[] args) {
    String resource = "mybatis-config.xml";
    InputStream inputStream = null;
    {
      try {
        inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = null;
        sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        RoleMapper mapper = sqlSession.getMapper(RoleMapper.class);
        Role role = mapper.getRole(1L);
        System.out.println(role.toString());
        //mapper.insertRole(new Role(1L,"许帅","许帅的备注"));
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
}
